#include <set.h>
class memBlock
{
public:
  memBlock(_ptlong _a,_ptlong _b):a(_a),b(_b){};
  bool operator<(const memBlock& b) const
  {
    return (a < b.a);
  }
  bool operator>(const memBlock& b) const
  {
    return (a > b.a);
  }
  bool operator==(const memBlock& b) const
  {
    return (((this->a >= b.a) && (this->a <= b.b))||((this->b >= b.a) && (this->b <= b.b)));
  }
  
  _ptlong a;
  _ptlong b;
};

class memBlocks
{
public:
  inline memBlocks(_ptlong _up,_ptlong _down,_ptlong _blocksize)
    :up(_up),down(_down),blockSize(_blocksize){};
  _ptlong* PopGroup(_ptlong blocknum);
  _ptlong PushGroup(_ptlong* addr,_ptlong blocknum);
  _ptlong PushGroup(_ptlong* addr);
private:
  set<memBlock> blocks;
  _ptlong up;
  _ptlong down;
  _ptlong blockSize;
};
